package cn.hchaojie.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
		String name = req.getParameter("name");
		String password = req.getParameter("password");
		
		if ("admin".equals(name) && "admin".equals(password)) {
			// 跳到成功页面
			response.sendRedirect("success.jsp");
		} else {
			req.setAttribute("error", "用户名密码不对！");

			// 跳到登陆页面
			req.getRequestDispatcher("login.jsp").forward(req, response);
		}
	}
}
